<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="author" content="esy">
    
    <meta name="description" content="esy">
    
    
    
    
    
    
    <title>在UI界面中加入时间测试 | ESY</title>
    <link href="https://esyyes.github.io" rel="prefetch" />

    
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/aos.css">
<link rel="stylesheet" href="/css/style.css">

    
<script src="/js/jquery.min.js"></script>

    
<script src="/js/bootstrap.min.js"></script>

    
<script src="/js/aos.js"></script>

    
<script src="/js/highslide/highslide-full.min.js"></script>

    
<link rel="stylesheet" href="/js/highslide/highslide.css">

    <style type="text/css">
        @media (max-width: 768px) {
            body {
                background-color: #f0f0f0;
                background: url('/imgs/xsbg.gif');
                background-attachment: fixed;
            }
        }
    </style>
    
    <!--<script type="text/javascript">
      if (document.images) {
        var avatar = new Image();
        avatar.src = '/imgs/avatar.jpg'
        var previews = 'preview1.jpg,preview2.jpg,preview3.jpg,preview4.jpg'.split(',')
        var previewsPreLoad = []
        for(var i = 0; i < length; i++) {
          previewsPreLoad.push(new Image())
          previewsPreLoad[previewsPreLoad.length - 1].src = '/imgs/preview' + previews[i]
        }
      }
    </script>-->
<meta name="generator" content="Hexo 5.2.0"></head>
<body>
    <!-- 背景轮播图功能 -->
    <section class="hidden-xs">
    <ul class="cb-slideshow">
        <li><span>天若</span></li>
        <li><span>有情</span></li>
        <li><span>天亦老</span></li>
        <li><span>我为</span></li>
        <li><span>长者</span></li>
        <li><span>续一秒</span></li>
    </ul>
</section>
    <!-- 欧尼酱功能, 谁用谁知道 -->
    
    <div class="gal-menu gal-dropdown">
    <div class="circle" id="gal">
        <div class="ring">
            <a href="https://esyyes.github.io" class="menuItem" style="left: 50%; top: 15%;">首页</a>
            
            <a class="menuItem" style="left: 80.3109%; top: 32.5%;">下一页</a>
            
            <a href="/archives" class="menuItem" style="left: 80.3109%; top: 67.5%;">归档</a>
            <a href="/about" class="menuItem" style="left: 50%; top: 85%;">关于</a>
            <a href="/message" class="menuItem" style="left: 19.6891%; top: 67.5%;">留言板</a>

            
            <a class="menuItem" style="left: 19.6891%; top: 32.5%;">上一页</a>
            
        </div>
        <audio id="audio" src="/imgs/oni.mp3"></audio>
    </div>
</div>
    
    <header class="navbar navbar-inverse" id="gal-header">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed"
                    data-toggle="collapse" data-target=".bs-navbar-collapse"
                    aria-expanded="false">
                <span class="fa fa-lg fa-reorder"></span>
            </button>
            <a href="https://esyyes.github.io">
                
                <style>
                    #gal-header .navbar-brand {
                        height: 54px;
                        line-height: 24px;
                        font-size: 28px;
                        opacity: 1;
                        background-color: rgba(0,0,0,0);
                        text-shadow: 0 0 5px #fff,0 0 10px #fff,0 0 15px #fff,0 0 20px #228DFF,0 0 35px #228DFF,0 0 40px #228DFF,0 0 50px #228DFF,0 0 75px #228DFF;
                    }
                </style>
                <!-- 这里使用文字(navbar_text or config.title) -->
                <div class="navbar-brand">ESY</div>
                
            </a>
        </div>
        <div class="collapse navbar-collapse bs-navbar-collapse">
            <ul class="nav navbar-nav" id="menu-gal">
                
                
                <li class="">
                    <a href="/">
                        <i class="fa fa-home"></i>首页
                    </a>
                </li>
                
                
                
                <li class="">
                    <a href="/archives">
                        <i class="fa fa-archive"></i>归档
                    </a>
                </li>
                
                
                
                
                <li class="dropdown">
                    <!-- TODO 添加hover dropdown效果 -->
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false" data-hover="dropdown">
                        <i class="fa fa-list"></i>分类
                    </a>
                    <ul class="dropdown-menu">
                        
                        
                        <li>
                            <a href="/categories/py-study/">py_study</a>
                        </li>
                        
                        <li>
                            <a href="/categories/nlp/">nlp</a>
                        </li>
                        
                        <li>
                            <a href="/categories/Graduation-work/">Graduation work</a>
                        </li>
                        
                        <li>
                            <a href="/categories/work/">work</a>
                        </li>
                        
                        <li>
                            <a href="/categories/hexo/">hexo</a>
                        </li>
                        
                        <li>
                            <a href="/categories/hexo%E5%AE%8C%E5%96%84/">-hexo完善</a>
                        </li>
                        
                        
                        <li>
                            <a href="/categories">...</a>
                        </li>
                        
                        
                    </ul>
                </li>
                
                
                
                
                
                <li class="dropdown">
                    <!-- TODO 添加hover dropdown效果 -->
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false" data-hover="dropdown">
                        <i class="fa fa-tags"></i>标签
                    </a>
                    <ul class="dropdown-menu">
                        
                        
                        <li>
                            <a href="/tags/py-study/">py_study</a>
                        </li>
                        
                        <li>
                            <a href="/tags/nlp/">nlp</a>
                        </li>
                        
                        <li>
                            <a href="/tags/Graduation-work/">Graduation work</a>
                        </li>
                        
                        <li>
                            <a href="/tags/work/">work</a>
                        </li>
                        
                        <li>
                            <a href="/tags/hexo/">hexo</a>
                        </li>
                        
                        <li>
                            <a href="/tags/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/">-个人博客搭建</a>
                        </li>
                        
                        
                        <li>
                            <a href="/tags">...</a>
                        </li>
                        
                        
                    </ul>
                </li>
                
                
                
                
                <li class="">
                    <a href="/about">
                        <i class="fa fa-user"></i>关于我
                    </a>
                </li>
                
                
            </ul>
        </div>
    </div>
</header>
    <div id="gal-body">
        <div class="container">
            <div class="row">
                <div class="col-md-8 gal-right" id="mainstay">
                    
<article class="article well article-body" id="article">
    <div class="breadcrumb">
        <i class="fa fa-home"></i>
        <a href="https://esyyes.github.io">ESY</a>
        >
        <span>在UI界面中加入时间测试</span>
    </div>
    <!-- 大型设备详细文章 -->
    <div class="hidden-xs">
        <div class="title-article">
            <h1>
                <a href="/2020/08/08/python%20work/%E5%9C%A8UI%E7%95%8C%E9%9D%A2%E4%B8%AD%E5%8A%A0%E5%85%A5%E6%97%B6%E9%97%B4%E6%B5%8B%E8%AF%95/">在UI界面中加入时间测试</a>
            </h1>
        </div>
        <div class="tag-article">
            
            <span class="label label-gal">
                <i class="fa fa-tags"></i>
                
                <a href="/tags/python/">python</a>
                
            </span>
            
            <span class="label label-gal">
                <i class="fa fa-calendar"></i> 2020-08-08
            </span>
            
        </div>
    </div>
    <!-- 小型设备详细文章 -->
    <div class="visible-xs">
        <center>
            <div class="title-article">
                <h4>
                    <a href="/2020/08/08/python%20work/%E5%9C%A8UI%E7%95%8C%E9%9D%A2%E4%B8%AD%E5%8A%A0%E5%85%A5%E6%97%B6%E9%97%B4%E6%B5%8B%E8%AF%95/">在UI界面中加入时间测试</a>
                </h4>
            </div>
            <p>
                <i class="fa fa-calendar"></i> 2020-08-08
            </p>
            <p>
                
                <i class="fa fa-tags"></i>
                
                <a href="/tags/python/">python</a>
                
                
                
            </p>
        </center>
    </div>
    <div class="content-article">
        <h1 id="在UI界面中加入时间测试"><a href="#在UI界面中加入时间测试" class="headerlink" title="在UI界面中加入时间测试"></a>在UI界面中加入时间测试</h1><p>是多次运行了字典的生成</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"><span class="comment"># @Time     : 2020/8/8</span></span><br><span class="line"><span class="comment"># @Author   : esy</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> tkinter <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">import</span> tkinter <span class="keyword">as</span> tk</span><br><span class="line"><span class="keyword">from</span> PIL <span class="keyword">import</span> ImageTk, Image</span><br><span class="line"><span class="keyword">import</span> pandas <span class="keyword">as</span> pd</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">from</span> gui_chatbot <span class="keyword">import</span> *</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">data = pd.read_excel(<span class="string">&#x27;Q&amp;A pairs.xlsx&#x27;</span>)</span><br><span class="line">data1 = np.array(data).tolist()</span><br><span class="line"><span class="comment"># 将问题进行分词，还原成标准形式，并删除停靠词</span></span><br><span class="line">list_key = [del_stop(data1[i][<span class="number">0</span>]) <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data))]</span><br><span class="line"><span class="comment"># 将其转换为词典</span></span><br><span class="line">dictionary = corpora.Dictionary(list_key)</span><br><span class="line"><span class="comment"># 统计每个问题的关键词对应的词汇和出现的次数</span></span><br><span class="line">corpus_bow = [dictionary.doc2bow(word) <span class="keyword">for</span> word <span class="keyword">in</span> list_key]</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">hello = <span class="string">&quot;Nice to meet you! My name is BoBo. I&#x27;m glad to answer any questions about traveling in Beijing! How can I help you? &quot;</span> + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">questionlist = [<span class="string">&quot;If you have the following questions, please enter the number directly: &quot;</span>,</span><br><span class="line">                <span class="string">&quot;1: Are there any famous scenic spots in Beijing&quot;</span>,</span><br><span class="line">                <span class="string">&quot;2: What are the famous delicacies in Beijing&quot;</span>,</span><br><span class="line">                <span class="string">&quot;3: What&#x27;s the fare on the Beijing subway&quot;</span>,</span><br><span class="line">                <span class="string">&quot;4: Where can I rent a car in Beijing &quot;</span>,</span><br><span class="line">                <span class="string">&quot;5: What are the opening hours of the Forbidden City&quot;</span></span><br><span class="line">                ]</span><br><span class="line">answerlist = [<span class="string">&quot;There are many famous scenic spots in Beijing, such as the Forbidden City, Tian &#x27;anmen Square, the Great Wall at Badaling, the Summer Palace, the Bird&#x27;s Nest, the Old Summer Palace and so on&quot;</span>,</span><br><span class="line">              <span class="string">&quot;Beijing&#x27;s famous delicacies include Peking duck, old Beijing noodles with Fried sauce, Mutton cooked in a copper pan, Beijing Zhizi Barbecue, Fried liver, Fried tripe and so on&quot;</span>,</span><br><span class="line">              <span class="string">&quot;The subway fare in Beijing is usually between 3 and 10 yuan, and 25 to 50 yuan if you take the airport line&quot;</span>,</span><br><span class="line">              <span class="string">&quot;To tell the truth, it is very inconvenient for foreigners to rent a car in China, because they need to prepare and submit a lot of materials, such as the renter&#x27;s passport, the city residence permit for more than 1 year, the Chinese driving license, and a guarantor of the city&#x27;s household registration. The guarantor shall provide his/her household register, identity card, guarantee undertaking and so on. If you are only traveling for a short time, we suggest you take the subway, bus or taxi, which will be much more convenient&quot;</span>,</span><br><span class="line">              <span class="string">&quot;April 1st to October 31st (peak season) from Tuesday to Sunday 08:30 to 17:00, closed on Mondays; November 1 - March 31 of the following year (off-season) From Tuesday to Sunday 08:30-16:30, closed on Monday; Mondays are not closed during legal holidays.&quot;</span></span><br><span class="line">              ]</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">sendMsgEvent</span>(<span class="params">event</span>):</span>  <span class="comment"># 发送消息事件</span></span><br><span class="line">    <span class="keyword">if</span> event.keysym == <span class="string">&#x27;Return&#x27;</span>:</span><br><span class="line">        sendMsg()</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&#x27;break&#x27;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">sendMsg</span>():</span>  <span class="comment"># 发送消息</span></span><br><span class="line">    strMsg1 = <span class="string">&quot;user: &quot;</span> + time.strftime(<span class="string">&quot;%Y-%m-%d %H:%M:%S&quot;</span>, time.localtime()) + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">    txtMsgList.config(state=<span class="string">&#x27;normal&#x27;</span>)</span><br><span class="line">    txtMsgList.insert(END, strMsg1, <span class="string">&#x27;color&#x27;</span>)</span><br><span class="line">    txtMsgList.insert(END, txtMsg.get(<span class="string">&#x27;0.0&#x27;</span>, END))</span><br><span class="line">    <span class="comment"># 开始回复消息</span></span><br><span class="line">    answer = <span class="string">&quot;chatbot: &quot;</span> + time.strftime(<span class="string">&quot;%Y-%m-%d %H:%M:%S&quot;</span>, time.localtime()) + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">    best = run_gui_chatbot(txtMsg.get(<span class="string">&#x27;0.0&#x27;</span>, END)[:<span class="number">-1</span>], dictionary, corpus_bow, data1) + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">    txtMsgList.insert(END, answer, <span class="string">&#x27;color&#x27;</span>)</span><br><span class="line">    <span class="keyword">if</span> txtMsg.get(<span class="string">&#x27;0.0&#x27;</span>, END)[:<span class="number">-1</span>] == <span class="string">&#x27;1&#x27;</span>:</span><br><span class="line">        txtMsgList.insert(END, answerlist[<span class="number">0</span>])</span><br><span class="line">        txtMsgList.insert(INSERT, <span class="string">&#x27;\n&#x27;</span>)</span><br><span class="line">    <span class="keyword">elif</span> txtMsg.get(<span class="string">&#x27;0.0&#x27;</span>, END)[:<span class="number">-1</span>] == <span class="string">&#x27;2&#x27;</span>:</span><br><span class="line">        txtMsgList.insert(END, answerlist[<span class="number">1</span>])</span><br><span class="line">        txtMsgList.insert(INSERT, <span class="string">&#x27;\n&#x27;</span>)</span><br><span class="line">    <span class="keyword">elif</span> txtMsg.get(<span class="string">&#x27;0.0&#x27;</span>, END)[:<span class="number">-1</span>] == <span class="string">&#x27;3&#x27;</span>:</span><br><span class="line">        txtMsgList.insert(END, answerlist[<span class="number">2</span>])</span><br><span class="line">        txtMsgList.insert(INSERT, <span class="string">&#x27;\n&#x27;</span>)</span><br><span class="line">    <span class="keyword">elif</span> txtMsg.get(<span class="string">&#x27;0.0&#x27;</span>, END)[:<span class="number">-1</span>] == <span class="string">&#x27;4&#x27;</span>:</span><br><span class="line">        txtMsgList.insert(END, answerlist[<span class="number">3</span>])</span><br><span class="line">        txtMsgList.insert(INSERT, <span class="string">&#x27;\n&#x27;</span>)</span><br><span class="line">    <span class="keyword">elif</span> txtMsg.get(<span class="string">&#x27;0.0&#x27;</span>, END)[:<span class="number">-1</span>] == <span class="string">&#x27;5&#x27;</span>:</span><br><span class="line">        txtMsgList.insert(END, answerlist[<span class="number">4</span>])</span><br><span class="line">        txtMsgList.insert(INSERT, <span class="string">&#x27;\n&#x27;</span>)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        txtMsgList.insert(END, best)</span><br><span class="line"></span><br><span class="line">    txtMsgList.config(state=<span class="string">&#x27;disabled&#x27;</span>)</span><br><span class="line">    txtMsgList.yview(END)</span><br><span class="line">    txtMsg.delete(<span class="string">&#x27;0.0&#x27;</span>, END)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 创建窗口</span></span><br><span class="line">start1 = time.time()</span><br><span class="line">root = Tk()</span><br><span class="line"><span class="comment"># 标题</span></span><br><span class="line">root.title(<span class="string">&#x27;Q&amp;A chatbot&#x27;</span>)</span><br><span class="line"><span class="comment"># 读取图标</span></span><br><span class="line">root.iconbitmap(<span class="string">&#x27;F:\s.ico&#x27;</span>)</span><br><span class="line"><span class="comment"># 窗口大小</span></span><br><span class="line">root.geometry(<span class="string">&#x27;800x650+300+100&#x27;</span>)</span><br><span class="line"><span class="comment"># 固定窗口</span></span><br><span class="line">root.resizable(width=<span class="literal">False</span>, height=<span class="literal">False</span>)</span><br><span class="line"><span class="comment"># 背景</span></span><br><span class="line">canvas = tk.Canvas(root, width=<span class="number">800</span>, height=<span class="number">650</span>, bd=<span class="number">0</span>, highlightthickness=<span class="number">0</span>)</span><br><span class="line">imgpath = <span class="string">&#x27;3.gif&#x27;</span></span><br><span class="line">img = Image.<span class="built_in">open</span>(imgpath).resize((<span class="number">800</span>, <span class="number">650</span>))</span><br><span class="line">photo = ImageTk.PhotoImage(img)</span><br><span class="line">canvas.create_image(<span class="number">400</span>, <span class="number">325</span>, image=photo)</span><br><span class="line">canvas.grid()</span><br><span class="line"></span><br><span class="line">start2 = time.time()</span><br><span class="line">brack21 = start2 - start1</span><br><span class="line">print(<span class="string">f&#x27;生成背景花费时间：<span class="subst">&#123;brack21&#125;</span>&#x27;</span>)</span><br><span class="line"><span class="comment"># 发送信息框</span></span><br><span class="line">txtMsg = Text(root, font=(<span class="string">&#x27;Times New Roman&#x27;</span>, <span class="number">15</span>))</span><br><span class="line">txtMsg.grid()</span><br><span class="line">canvas.create_window(<span class="number">400</span>, <span class="number">500</span>, width=<span class="number">650</span>, height=<span class="number">200</span>, window=txtMsg)</span><br><span class="line">start3 = time.time()</span><br><span class="line"><span class="comment"># 绑定一个控制键，进行发送信息</span></span><br><span class="line">txtMsg.bind(<span class="string">&quot;&lt;KeyPress-Return&gt;&quot;</span>, sendMsgEvent)</span><br><span class="line">button = Button(root, text=<span class="string">&#x27;Send (S)&#x27;</span>, font=(<span class="string">&#x27;Times New Roman&#x27;</span>, <span class="number">12</span>), command=sendMsg, bg=<span class="string">&quot;#afb4db&quot;</span>)</span><br><span class="line">button.grid()</span><br><span class="line">canvas.create_window(<span class="number">685</span>, <span class="number">615</span>, width=<span class="number">80</span>, height=<span class="number">30</span>, window=button)</span><br><span class="line">start4 = time.time()</span><br><span class="line">brack43 = start4 - start3</span><br><span class="line">print(<span class="string">f&#x27;发送点击消息花费时间：<span class="subst">&#123;brack43&#125;</span>&#x27;</span>)</span><br><span class="line"><span class="comment"># 布局1</span></span><br><span class="line">txtMsgList = Text(root, insertbackground=<span class="string">&#x27;#f6f5ec&#x27;</span>, font=(<span class="string">&#x27;Times New Roman&#x27;</span>, <span class="number">15</span>))</span><br><span class="line">txtMsgList.tag_config(<span class="string">&#x27;color&#x27;</span>, foreground=<span class="string">&#x27;#6a6da9&#x27;</span>)</span><br><span class="line">strMsg = <span class="string">&quot;BoBo: &quot;</span> + time.strftime(<span class="string">&quot;%Y-%m-%d %H:%M:%S&quot;</span>, time.localtime()) + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">txtMsgList.insert(END, strMsg, <span class="string">&#x27;color&#x27;</span>)</span><br><span class="line"><span class="comment"># 输入问候语</span></span><br><span class="line">txtMsgList.insert(END, hello)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 输入待查询的5个问题</span></span><br><span class="line">txtMsgList.insert(END, strMsg, <span class="string">&#x27;color&#x27;</span>)</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(questionlist)):</span><br><span class="line">    txtMsgList.insert(END, questionlist[i])</span><br><span class="line">    txtMsgList.insert(INSERT, <span class="string">&#x27;\n&#x27;</span>)</span><br><span class="line">txtMsgList.config(state=<span class="string">&#x27;disabled&#x27;</span>)</span><br><span class="line">txtMsgList.grid()</span><br><span class="line">canvas.create_window(<span class="number">400</span>, <span class="number">200</span>, width=<span class="number">650</span>, height=<span class="number">380</span>, window=txtMsgList)</span><br><span class="line">start5 = time.time()</span><br><span class="line">brack54 = start5 - start4</span><br><span class="line">print(<span class="string">f&#x27;消息回复花费时间：<span class="subst">&#123;brack54&#125;</span>&#x27;</span>)</span><br><span class="line"><span class="comment"># 滚动条</span></span><br><span class="line">scrollbar = Scrollbar(root, command=txtMsgList.yview, cursor=<span class="string">&quot;heart&quot;</span>)</span><br><span class="line">txtMsgList[<span class="string">&#x27;yscrollcommand&#x27;</span>] = scrollbar.<span class="built_in">set</span></span><br><span class="line">scrollbar.grid()</span><br><span class="line">canvas.create_window(<span class="number">730</span>, <span class="number">200</span>, width=<span class="number">10</span>, height=<span class="number">380</span>, window=scrollbar)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 消息循环 显示窗口</span></span><br><span class="line">root.mainloop()</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>gui_chatbot</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"><span class="comment"># @Time     : 2020/8/8</span></span><br><span class="line"><span class="comment"># @Author   : esy</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> gensim <span class="keyword">import</span> corpora, models, similarities</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> en_core_web_md</span><br><span class="line"><span class="keyword">import</span> random</span><br><span class="line"><span class="keyword">import</span> warnings</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">warnings.filterwarnings(<span class="string">&quot;ignore&quot;</span>)</span><br><span class="line"><span class="comment"># 加载语料库</span></span><br><span class="line">nlp = en_core_web_md.load()</span><br><span class="line">greeting_output = [<span class="string">&quot;hi&quot;</span>, <span class="string">&quot;hey&quot;</span>, <span class="string">&quot;hello&quot;</span>, <span class="string">&quot;I&#x27;m glad! You are talking to me&quot;</span>]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将句子进行分词，然后还原成原始形态，并删除停靠词，得到关键词</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">del_stop</span>(<span class="params">line</span>):</span></span><br><span class="line">    token_doc = [token.lemma_ <span class="keyword">for</span> token <span class="keyword">in</span> nlp(line)]</span><br><span class="line">    key_word = [word <span class="keyword">for</span> word <span class="keyword">in</span> token_doc <span class="keyword">if</span> <span class="keyword">not</span> nlp.vocab[word].is_stop != <span class="literal">False</span>]</span><br><span class="line">    <span class="keyword">return</span> key_word</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 加载TF_IDF模型，并建立索引，和得到相似度得分</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">TF_IDF</span>(<span class="params">corpus, text_bow</span>):</span></span><br><span class="line">    <span class="comment"># 利用语料生成tfidf</span></span><br><span class="line">    tfidf = models.TfidfModel(corpus)[corpus]</span><br><span class="line">    <span class="comment"># 将输入的问题进行分词，然后转换为词向量</span></span><br><span class="line">    index = similarities.MatrixSimilarity(tfidf)</span><br><span class="line">    <span class="comment"># 利用索引排出测试语句的得分</span></span><br><span class="line">    similar_score = index[text_bow]</span><br><span class="line">    <span class="keyword">return</span> similar_score</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 召回5个问题</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">recall_qa</span>(<span class="params">similar_score, df</span>):</span></span><br><span class="line">    <span class="comment"># 将其转换为字典并进行排序，然后召回5个问题，最后输出相似度</span></span><br><span class="line">    dict_score = <span class="built_in">dict</span>(<span class="built_in">zip</span>(np.arange(<span class="built_in">len</span>(df)), similar_score))</span><br><span class="line">    <span class="comment"># sorted, reverse -- 排序规则，reverse = True 降序 ， reverse = False 升序（默认）,降序排列</span></span><br><span class="line">    sort_score = <span class="built_in">sorted</span>(<span class="built_in">zip</span>(dict_score.values(), dict_score.keys()), reverse=<span class="literal">True</span>)</span><br><span class="line">    <span class="comment"># 通过相似度得分，得到5个问题</span></span><br><span class="line">    recall_5 = [df[sort_score[i][<span class="number">1</span>]] <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">5</span>)]</span><br><span class="line">    recall_s = [sort_score[i][<span class="number">0</span>] <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">5</span>)]</span><br><span class="line">    <span class="keyword">return</span> recall_s, recall_5</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 利用spacy获取这5个问题与输入的相似度</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">similar_spacy</span>(<span class="params">text, recall_ques</span>):</span></span><br><span class="line">    similar_goal = [nlp(text).similarity(nlp(recall_ques[i][<span class="number">0</span>])) <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(recall_ques))]</span><br><span class="line">    <span class="keyword">return</span> similar_goal</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 获取这5个问题在这5个问题下对应的词汇和向量</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">bow5_question</span>(<span class="params">recall_aq1, text</span>):</span></span><br><span class="line">    list_qa = [del_stop(recall_aq1[i][<span class="number">0</span>]) <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">5</span>)]</span><br><span class="line">    dictionary1 = corpora.Dictionary(list_qa)</span><br><span class="line">    corpus_bow1 = [dictionary1.doc2bow(word) <span class="keyword">for</span> word <span class="keyword">in</span> list_qa]</span><br><span class="line">    input_bow1 = dictionary1.doc2bow(del_stop(text))</span><br><span class="line">    <span class="keyword">return</span> corpus_bow1, input_bow1, dictionary1</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 利用lsi输出5个问题的相似度</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">similar_lsi</span>(<span class="params">corpus_bow1, input_bow1, dictionary1, n</span>):</span></span><br><span class="line">    lsi = models.LsiModel(corpus_bow1, id2word=dictionary1, num_topics=n)</span><br><span class="line">    index = similarities.MatrixSimilarity(lsi[corpus_bow1])</span><br><span class="line">    similar = index[lsi[input_bow1]].tolist()</span><br><span class="line">    <span class="keyword">return</span> similar</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 利用lda输出5个问题的相似度</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">similar_lda</span>(<span class="params">corpus_bow1, input_bow1, dictionary1, n</span>):</span></span><br><span class="line">    lda = models.LdaModel(corpus_bow1, id2word=dictionary1, num_topics=n)</span><br><span class="line">    index = similarities.MatrixSimilarity(lda[corpus_bow1])</span><br><span class="line">    similar = index[lda[input_bow1]].tolist()</span><br><span class="line">    <span class="keyword">return</span> similar</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 输出相似度最高的那个的答案，如果这个答案的相似度不到0.7返回sorry</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">best_answer</span>(<span class="params">list_num, recall_5</span>):</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">max</span>(list_num) &lt;= <span class="number">0.7</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="string">f&quot;I&#x27;m sorry. I don&#x27;t understand you&quot;</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        best_ans = recall_5[list_num.index(<span class="built_in">max</span>(list_num))][<span class="number">1</span>]</span><br><span class="line">        <span class="keyword">return</span> best_ans</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">run_print_chatbot</span>(<span class="params">data</span>):</span></span><br><span class="line">    data1 = np.array(data).tolist()</span><br><span class="line">    <span class="comment"># 将问题进行分词，还原成标准形式，并删除停靠词</span></span><br><span class="line">    list_key = [del_stop(data1[i][<span class="number">0</span>]) <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data))]</span><br><span class="line">    <span class="comment"># 将其转换为词典</span></span><br><span class="line">    dictionary = corpora.Dictionary(list_key)</span><br><span class="line">    <span class="comment"># 统计每个问题的关键词对应的词汇和出现的次数</span></span><br><span class="line">    corpus_bow = [dictionary.doc2bow(word) <span class="keyword">for</span> word <span class="keyword">in</span> list_key]</span><br><span class="line">    <span class="comment"># input_text = &#x27;How long will it take me to visit the Forbidden City&#x27;</span></span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        <span class="comment"># 输入问题</span></span><br><span class="line">        input_text = <span class="built_in">input</span>(<span class="string">&#x27;请输入问题：&#x27;</span>)</span><br><span class="line">        <span class="comment"># 将问题进行转换为基础形式</span></span><br><span class="line">        text1 = <span class="string">&quot; &quot;</span>.join([token.lemma_ <span class="keyword">for</span> token <span class="keyword">in</span> nlp(input_text)])</span><br><span class="line">        <span class="keyword">if</span> text1 == <span class="string">&#x27;hey&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;hi&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;hello&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;HI&#x27;</span>:</span><br><span class="line">            print(random.choice(greeting_output))</span><br><span class="line">        <span class="keyword">elif</span> text1 == <span class="string">&#x27;thank&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;thank -PRON-&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;THANK&#x27;</span>:</span><br><span class="line">            print(<span class="string">&#x27;You are welcome.&#x27;</span>)</span><br><span class="line">        <span class="keyword">elif</span> <span class="built_in">len</span>(text1.split()) &lt; <span class="number">3</span>:</span><br><span class="line">            print(<span class="string">f&quot;I&#x27;m sorry. I don&#x27;t understand you&quot;</span>)</span><br><span class="line">        <span class="keyword">elif</span> text1 == <span class="string">&#x27;bye&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;BYE&#x27;</span>:</span><br><span class="line">            print(<span class="string">&#x27;Bye!&#x27;</span>)</span><br><span class="line">            <span class="keyword">break</span></span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            input_bow = dictionary.doc2bow(del_stop(input_text))</span><br><span class="line">            tfidf_score, recall_aq = recall_qa(TF_IDF(corpus_bow, input_bow), data1)</span><br><span class="line">            corpus_bow5, input_bow5, dictionary5 = bow5_question(recall_aq, input_text)</span><br><span class="line">            <span class="comment"># similar_tf = TF_IDF(corpus_bow5, input_bow5)</span></span><br><span class="line">            spacy_score = similar_spacy(input_text, recall_aq)</span><br><span class="line">            lsi_sim = similar_lsi(corpus_bow5, input_bow5, dictionary5, <span class="number">5</span>)</span><br><span class="line">            lda_sim = similar_lda(corpus_bow5, input_bow5, dictionary5, <span class="number">5</span>)</span><br><span class="line">            <span class="comment"># 将其转换为词典</span></span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">5</span>):</span><br><span class="line">                print(<span class="string">f&#x27;tf-idf召回得分：<span class="subst">&#123;tfidf_score[i]&#125;</span>&#x27;</span>, end=<span class="string">&#x27;\t&#x27;</span>)</span><br><span class="line">                print(<span class="string">f&#x27;<span class="subst">&#123;recall_aq[i][<span class="number">0</span>]&#125;</span>&#x27;</span>)</span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">5</span>):</span><br><span class="line">                print(<span class="string">f&#x27;召回的5个问题的相似度比较&#x27;</span>)</span><br><span class="line">                print(<span class="string">f&#x27;<span class="subst">&#123;tfidf_score[i]&#125;</span>&#x27;</span>, end=<span class="string">&#x27;\t&#x27;</span>)</span><br><span class="line">                print(<span class="string">f&#x27;<span class="subst">&#123;spacy_score[i]&#125;</span>&#x27;</span>, end=<span class="string">&#x27;\t&#x27;</span>)</span><br><span class="line">                print(<span class="string">f&#x27;<span class="subst">&#123;lsi_sim[i]&#125;</span>&#x27;</span>, end=<span class="string">&#x27;\t&#x27;</span>)</span><br><span class="line">                print(<span class="string">f&#x27;<span class="subst">&#123;lda_sim[i]&#125;</span>&#x27;</span>)</span><br><span class="line">            print(<span class="string">f&#x27;通过相似度得分召回的问题&#x27;</span>)</span><br><span class="line">            print(<span class="string">f&#x27;tfidf召回问题：<span class="subst">&#123;best_answer(tfidf_score, recall_aq)&#125;</span>&#x27;</span>)</span><br><span class="line">            print(<span class="string">f&#x27;spacy召回问题：<span class="subst">&#123;best_answer(spacy_score, recall_aq)&#125;</span>&#x27;</span>)</span><br><span class="line">            print(<span class="string">f&#x27;lsi召回问题：<span class="subst">&#123;best_answer(lsi_sim, recall_aq)&#125;</span>&#x27;</span>)</span><br><span class="line">            print(<span class="string">f&#x27;lda召回问题：<span class="subst">&#123;best_answer(lda_sim, recall_aq)&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">run_gui_chatbot</span>(<span class="params">input_text, dictionary, corpus_bow, data1</span>):</span></span><br><span class="line">    <span class="comment"># 将问题进行转换为基础形式</span></span><br><span class="line">    text1 = <span class="string">&quot; &quot;</span>.join([token.lemma_ <span class="keyword">for</span> token <span class="keyword">in</span> nlp(input_text)])</span><br><span class="line">    <span class="keyword">if</span> text1 == <span class="string">&#x27;hey&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;hi&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;hello&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;HI&#x27;</span>:</span><br><span class="line">        <span class="keyword">return</span> random.choice(greeting_output)</span><br><span class="line">    <span class="keyword">elif</span> text1 == <span class="string">&#x27;thank&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;thank -PRON-&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;THANK&#x27;</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&#x27;You are welcome.&#x27;</span></span><br><span class="line">    <span class="keyword">elif</span> text1 == <span class="string">&#x27;bye&#x27;</span> <span class="keyword">or</span> text1 == <span class="string">&#x27;BYE&#x27;</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&#x27;Bye!&#x27;</span></span><br><span class="line">    <span class="keyword">elif</span> <span class="built_in">len</span>(text1.split()) &lt; <span class="number">3</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;I&#x27;m sorry. I don&#x27;t understand you&quot;</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        input_bow = dictionary.doc2bow(del_stop(input_text))</span><br><span class="line">        tfidf_score, recall_aq = recall_qa(TF_IDF(corpus_bow, input_bow), data1)</span><br><span class="line">        <span class="keyword">return</span> best_answer(tfidf_score, recall_aq)</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2264591029,1715315828&fm=26&gp=0.jpg"></p>

    </div>
</article>


                </div>
                <aside class="col-md-4 gal-left" id="sidebar">
    <!-- 此为sidebar的搜索框, 非搜索结果页面 -->
<aside id="sidebar-search">
    <div class="search hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <form class="form-inline clearfix" id="search-form" method="get"
              action="/search/index.html">
            <input type="text" name="s" class="form-control" id="searchInput" placeholder="搜索文章~" autocomplete="off">
            <button class="btn btn-danger btn-gal" type="submit">
                <i class="fa fa-search"></i>
            </button>
        </form>
    </div>
</aside>
    <aside id="sidebar-author">
    <div class="panel panel-gal" data-aos="flip-right" data-aos-duration="3000">
        <div class="panel-heading" style="text-align: center">
            <i class="fa fa-quote-left"></i>
            esy
            <i class="fa fa-quote-right"></i>
        </div>
        <div class="author-panel text-center">
            <img src="/imgs/avatar.jpg" width="140" height="140"
                 alt="个人头像" class="author-image">
            <p class="author-description"><p>esy</p>
</p>
        </div>
    </div>
</aside>
    
    <aside id="sidebar-recent_comments">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-comments"></i>
            最新评论
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush"></ul>
    </div>
</aside>
    
    <!-- 要配置好leancloud才能开启此小工具 -->
    
    
    <aside id="sidebar-recent_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            近期文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/05/python%20work/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95/">最小二乘法</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/05/python%20work/%E7%BB%9F%E8%AE%A1%E5%AD%A6%E4%B9%A0-%E7%AC%AC%E4%B8%80%E7%AB%A0/">统计学习--第一章</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/04/python%20work/hello-world/">Hello World</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/03/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%AF%84%E4%BC%B0%E6%8C%87%E6%A0%87/">分类模型的评估指标</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/10/21/python%20work/10-21-%E7%88%AC%E8%99%AB%E5%9F%BA%E7%A1%80/">10-21 爬虫基础</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/CRF%E7%9A%84%E6%95%B4%E4%BD%93%E6%B5%81%E7%A8%8B%E7%BB%93%E6%9E%9C/">CRF的整体流程结果</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/nlp-crf%E6%A8%A1%E5%9E%8B/">nlp_crf模型</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%983/">数学建模问题3</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%982/">数学建模问题2</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%981/">数学建模问题1</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="sidebar-rand_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            随机文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/10/21/python%20work/10-21-%E7%88%AC%E8%99%AB%E5%9F%BA%E7%A1%80/">10-21 爬虫基础</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/07/22/python%20work/chatbot-sorry%E7%AF%87/">chatbot_sorry篇</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/04/12/python%20work/python-Matplotlib%E8%A7%86%E9%A2%91%E8%AE%B2%E8%A7%A3%E7%89%88/">python-Matplotlib视频讲解版</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/02/26/python%20work/python%E2%80%94%E2%80%94%E5%91%BC%E5%90%B8%E9%9F%B3%E7%89%B9%E5%BE%81/">python</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/03/25/python%20work/python%E2%80%94%E2%80%94%E8%AF%BB%E5%8F%96excel%E6%96%87%E4%BB%B6%E4%B9%8B%E5%A5%87%E8%91%A9%E6%95%B0%E6%8D%AE/">python——读取excel文件之奇葩数据</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2019/12/01/python%20work/python%E5%9F%BA%E7%A1%80%E4%B9%8B%E7%BB%98%E5%88%B6%E5%88%97%E8%A1%A8%E6%96%87%E4%BB%B6/">LV-1</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2019/12/26/python%20work/python%E8%B0%83%E7%94%A8wfdb/">LV-3</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%982/">数学建模问题2</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/06/08/python%20work/%E6%A0%87%E7%AD%BE%E5%92%8C%E7%89%B9%E5%BE%81%E9%95%BF%E5%BA%A6%E5%A4%84%E7%90%86/">标签和特征长度处理</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/08/20/python%20work/%E9%87%8D%E6%96%B0%E6%9E%84%E5%BB%BAslpdb%E4%B8%AD%E7%9A%84%E7%89%B9%E5%BE%81%E5%92%8C%E6%A0%87%E7%AD%BE/">重新构建slpdb中的特征和标签</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="gal-sets">
        <div class="panel panel-gal hidden-xs" data-aos="fade-up" data-aos-duration="2000">
            <ul class="nav nav-pills pills-gal">

                
                <li>
                    <a href="/2020/08/08/python%20work/%E5%9C%A8UI%E7%95%8C%E9%9D%A2%E4%B8%AD%E5%8A%A0%E5%85%A5%E6%97%B6%E9%97%B4%E6%B5%8B%E8%AF%95/index.html#sidebar-tags" data-toggle="tab" id="tags-tab">热门标签</a>
                </li>
                
                
                <li>
                    <a href="/2020/08/08/python%20work/%E5%9C%A8UI%E7%95%8C%E9%9D%A2%E4%B8%AD%E5%8A%A0%E5%85%A5%E6%97%B6%E9%97%B4%E6%B5%8B%E8%AF%95/index.html#sidebar-friend-links" data-toggle="tab" id="friend-links-tab">友情链接</a>
                </li>
                
                
                <li>
                    <a href="/2020/08/08/python%20work/%E5%9C%A8UI%E7%95%8C%E9%9D%A2%E4%B8%AD%E5%8A%A0%E5%85%A5%E6%97%B6%E9%97%B4%E6%B5%8B%E8%AF%95/index.html#sidebar-links" data-toggle="tab" id="links-tab">个人链接</a>
                </li>
                
            </ul>
            <div class="tab-content">
                
                <div class="cloud-tags tab-pane nav bs-sidenav fade" id="sidebar-tags">
    
    <a href="/tags/py-study/" style="font-size: 14.99329121155927px;" class="tag-cloud-link">py_study</a>
    
    <a href="/tags/nlp/" style="font-size: 10.248584996671553px;" class="tag-cloud-link">nlp</a>
    
    <a href="/tags/Graduation-work/" style="font-size: 8.328209723399416px;" class="tag-cloud-link">Graduation work</a>
    
    <a href="/tags/work/" style="font-size: 9.4626439351383px;" class="tag-cloud-link">work</a>
    
    <a href="/tags/hexo/" style="font-size: 10.484222185608957px;" class="tag-cloud-link">hexo</a>
    
    <a href="/tags/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" style="font-size: 8.025753739764259px;" class="tag-cloud-link">-个人博客搭建</a>
    
    <a href="/tags/malab-%E6%AF%95%E4%B8%9A/" style="font-size: 13.83154766321746px;" class="tag-cloud-link">-malab -毕业</a>
    
    <a href="/tags/python-%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/" style="font-size: 16.005738501523325px;" class="tag-cloud-link">-python -人工智能</a>
    
    <a href="/tags/python/" style="font-size: 17.139882678259575px;" class="tag-cloud-link">python</a>
    
    <a href="/tags/python/" style="font-size: 16.951536901904433px;" class="tag-cloud-link">-python</a>
    
    <a href="/tags/mathematical-modeling/" style="font-size: 10.906493556055509px;" class="tag-cloud-link">mathematical modeling</a>
    
    <a href="/tags/statistical-learning/" style="font-size: 11.958217854772807px;" class="tag-cloud-link">statistical learning</a>
    
</div>
                
                
                <div class="friend-links tab-pane nav bs-sidenav fade" id="sidebar-friend-links">
    
    <li>
        <a href="http://kdays.net/days/" target="_blank">KDays Forum</a>
    </li>
    
    <li>
        <a href="http://www.gal123.com/" target="_blank">绅士导航♂</a>
    </li>
    
    <li>
        <a href="http://www.moe123.com/" target="_blank">萌导航</a>
    </li>
    
</div>
                
                
                <div class="links tab-pane nav bs-sidenav fade" id="sidebar-links">
    
    <li>
        <a href="https://github.com/ZEROKISEKI/" target="_blank">Github</a>
    </li>
    
    <li>
        <a href="https://coding.net/u/SORA1" target="_blank">Coding</a>
    </li>
    
    <li>
        <a href="https://www.zhihu.com/people/aonosora/activities" target="_blank">知乎</a>
    </li>
    
</div>
                
            </div>
        </div>
    </aside>
    
</aside>
            </div>
        </div>
    </div>
    <footer id="gal-footer">
    <div class="container">
        Copyright © 2018 esy Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>.&nbsp;Theme by <a href="https://github.com/ZEROKISEKI" target="_blank">AONOSORA</a>
    </div>
</footer>

<!-- 回到顶端 -->
<div id="gal-gotop">
    <i class="fa fa-angle-up"></i>
</div>
</body>

<script src="/js/activate-power-mode.js"></script>

<script>

    // 配置highslide
	hs.graphicsDir = '/js/highslide/graphics/'
    hs.outlineType = "rounded-white";
    hs.dimmingOpacity = 0.8;
    hs.outlineWhileAnimating = true;
    hs.showCredits = false;
    hs.captionEval = "this.thumb.alt";
    hs.numberPosition = "caption";
    hs.align = "center";
    hs.transitions = ["expand", "crossfade"];
    hs.lang.number = '共%2张图, 当前是第%1张';
    hs.addSlideshow({
      interval: 5000,
      repeat: true,
      useControls: true,
      fixedControls: "fit",
      overlayOptions: {
        opacity: 0.75,
        position: "bottom center",
        hideOnMouseOut: true
      }
    })

    // 初始化aos
    AOS.init({
      duration: 1000,
      delay: 0,
      easing: 'ease-out-back'
    });

</script>
<script>
	POWERMODE.colorful = 'true';    // make power mode colorful
	POWERMODE.shake = 'true';       // turn off shake
	// TODO 这里根据具体情况修改
	document.body.addEventListener('input', POWERMODE);
</script>
<script>
    window.slideConfig = {
      prefix: '/imgs/slide/background',
      ext: 'jpg',
      maxCount: '6'
    }
</script>

<script src="/js/hs.js"></script>
<script src="/js/blog.js"></script>



<script src="/js/oni.js"></script>




</html>